package com.musemun.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;


import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import javax.validation.constraints.NotNull;

/**
 * <p>
 * 
 * </p>
 *
 * @author winner
 * @since 2020-04-27
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="Employee对象", description="")
public class Employee implements Serializable, UserDetails{

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "工号")
    @TableId(value = "eNo", type = IdType.AUTO)
    private Integer eNo;

    @NotNull(message = "姓名不能为空")
    @ApiModelProperty(value = "姓名")
    @TableField("eName")
    private String eName;

    @NotNull(message = "角色不能为空")
    @ApiModelProperty(value = "角色")
    private String roles;

    @ApiModelProperty(value = "密码")
    private String pwd;

//    @ApiModelProperty(value = "权限")
//    private String permit;

    @ApiModelProperty(value = "备注1")
    @TableField("Remarks")
    private String Remarks;
    @TableField(exist = false)
    private List<? extends GrantedAuthority> authorities;  //表示该用户所具有的全部角色

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return pwd;
    }

    @Override
    public String getUsername() {
        return eName;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

}